package com.onlinemarket.thrid.daoimpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;
import com.onlinemarket.thrid.dao.registerDao;
import com.onlinemarket.thrid.domain.User;

@Repository
public class registerImpl implements registerDao {
	@Autowired
	private JdbcTemplate jdbcTemplate;
	@Autowired
	private User user;

	@Override
	public void insertUser(User user) {
		String sql = "insert into user (user_name,user_password,user_sex,user_telephone,user_address) values(?,?,?,?,?)";
		jdbcTemplate.update(sql, new Object[] { user.getUser_name(), user.getUser_password(), user.getUser_sex(),
				user.getUser_telephone(), user.getUser_address() });
	}

	@Override
	public boolean checkUser(String user_name) {
		String tempusername = null;
		String sql = "select * from user where user_name=?";
		user = jdbcTemplate.queryForObject(sql, User.class, new Object[] { user_name });
		tempusername = user.getUser_name();
		if (user_name.equals(tempusername)) {
			return false;
		} else {
			return true;
		}
	}

}
